<%-- 
    Document   : crearUsuario
    Created on : 13/12/2008, 08:42:20 PM
    Author     : gabriel
--%>
<!--script type="text/javascript">
    alert("ver aqui");
</script-->

<%@ page import="java.util.*" %>
<%@ page import="connect.HandlerDB" %>

<!--%= session.getAttribute("hilo_id_")--%>
<!--%= session.getAttribute("user")--%>

<%
            HandlerDB objCon = new HandlerDB();
            objCon.openConnection();

            String sql = "SELECT MAX(user_id) FROM Usuario";
            Vector vr = objCon.query(sql);
            String xpers_id;
            if (vr ==null || vr.size() == 0 || ((Vector)vr.get(0))== null)
                xpers_id="99";
            else{
                vr = (Vector) vr.get(0);
                if (vr.get(0) == null)
                    xpers_id = "99";
                else
                    xpers_id = (String) vr.get(0);
            }
            int pers_id = Integer.parseInt(xpers_id) + 1;
            xpers_id=Integer.toString(pers_id);
            
            String xnombre_user = request.getParameter("nombre_user");
            String xtelefono_user = request.getParameter("telefono_user");
            String xdireccion_user = request.getParameter("direccion_user");
            String xuser_email = request.getParameter("user_email");
            String xpass_user = request.getParameter("pass_user");

            xnombre_user.trim();
            xtelefono_user.trim();
            xdireccion_user.trim();
            xuser_email.trim();
            xpass_user.trim();


            sql = "INSERT INTO Usuario (user_id,user_nombre,user_telefono,user_direccion,user_email,user_pass) ";
            sql += "VALUES (" + xpers_id+",'"+ xnombre_user +"'," + 
                                xtelefono_user +",'" + xdireccion_user+"','" + 
                                xuser_email+"','"+xpass_user+ "')";

            objCon.insert(sql);

            response.sendRedirect("index.jsp");
%>